package com.mysoap.simpledemo.client;

import java.rmi.RemoteException;

import javax.xml.namespace.QName;

import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;


public class MyServiceClient {
	public static void main(String[] args) throws RemoteException {
		String address = "http://localhost:8080/MySoap/services/myService";		
		String str = "{}";  
        // 建立一个远程连接客户端  
        RPCServiceClient serviceClient = new RPCServiceClient();  
        // 设置参数  
        Options options = serviceClient.getOptions();  
        // 设置调用的方法  
        options.setAction("getGreeting");  
        // 设置webservice调用地址 本机测试就用 本地的webservice地址  
        // 远程webservice服务地址  
        EndpointReference targetEPR = new EndpointReference(address);  
        options.setTo(targetEPR);  
        // 调用远程方法的参数  
        Object[] opAddEntryArgs = new Object[] { "zhangsan" };  
        // 返回结果类型  
        Class[] classes = new Class[] { String.class };  
        serviceClient.setTargetEPR(targetEPR);  
        //此处的是 实现类所在的包的倒序  
        QName opAddEntry = new QName("http://simpledemo.mysoap.com", "getGreeting");  
        str = serviceClient.invokeBlocking(opAddEntry, opAddEntryArgs, classes)[0].toString();  
        serviceClient.cleanupTransport();  
        System.out.println(str);  
	}
}
